package models;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * Created by xieyicheng on 2015/1/22.
 */
@Entity
@Table(name = "collection")
public class Collection  extends BasicModel {

    //收藏作品和收藏的专辑
    public final static int WORK=1;
    public final static int ALBUM=0;

    // 收藏的人的id
    @Column(name = "owner_id")
    public String owner_id;

    // 收藏的对象的id
    @Column(name = "collect_id")
    public String collect_id;

    // 状态
    @Column(name = "type")
    public int type;
    
    public static void deleteRelatedCollection(String objectId,int type)
    {
    	List<Collection> collectionList = Collection.find("collect_id = ? and type = ?", objectId,type).fetch();
    	for(int i = 0;i < collectionList.size();i++)
    	{
    		collectionList.get(i).delete();
    	}
    }

}
